import { MailerModule } from '@nestjs-modules/mailer'
import { Module } from '@nestjs/common'
import { EjsAdapter } from '@nestjs-modules/mailer/dist/adapters/ejs.adapter'
import path from 'path'
import { emailService } from './email.service'
import { EmailController } from './email.controller'
const { EMAIL_PASS, EMAIL_USER } = process.env

@Module({
  imports: [
    MailerModule.forRoot({
      transport: {
        host: 'smtp.163.com',
        port: 465, //服务器端口 默认 465
        auth: {
          user: `${EMAIL_USER}`,
          pass: `${EMAIL_PASS}`,
        },
      },
      defaults: {
        from: `${EMAIL_USER}`, //发送人 你的邮箱地址
      },
      template: {
        dir: path.join(process.cwd(), './src/common/modules/email/template'), //这里就是你的ejs模板文件夹路径
        adapter: new EjsAdapter(),
        options: {
          strict: true, //严格模式
        },
      },
    }),
  ],
  controllers: [EmailController],
  providers: [emailService],
  exports: [emailService],
})
export class EmailModule {}
